#include <bits/stdc++.h>
using namespace std;
const int maxn=110;
double a[maxn];
double sum[maxn];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	int n;
	cin >> n;
	double summ=0;
	for(int i=1;i<=n;i++)
	{
		cin >> a[i];
	}
	int x,y;
	while(true)
	{
		cin >> x >> y;
		if(x==0)
		{
			break;
		}
		sum[x]=sum[x]+y;
		summ=summ+a[x]*y;
	}
	for(int i=1;i<=n;i++)
	{
		cout << sum[i] << endl;
	}
	cout << fixed << setprecision(2) << summ << endl;
	return 0;
}
